package com.scorpio.scbasics.bizuser.service.impl;

import java.util.Arrays;
import java.util.List;
import com.scorpio.common.service.impl.BaseServiceImpl;
import com.scorpio.common.utils.StringUtils;
import com.scorpio.scbasics.bizgoddessauth.dto.BizGoddessAuthDTO;
import com.scorpio.scbasics.bizlocation.domain.BizLocationEntity;
import com.scorpio.scbasics.bizlocation.dto.BizLocationDTO;
import com.scorpio.scbasics.bizmemorandum.domain.BizMemorandumEntity;
import com.scorpio.scbasics.bizmemorandum.dto.BizMemorandumDTO;
import com.scorpio.scbasics.bizsms.dto.BizSmsDTO;
import com.scorpio.scbasics.bizuser.domain.BizUserEntity;
import com.scorpio.scbasics.bizuser.dto.BizUserDTO;
import com.scorpio.scbasics.bizuser.mapper.BizUserMapper;
import com.scorpio.scbasics.bizuser.service.IBizUserService;
import com.scorpio.scbasics.bizuseronline.dto.BizUserOnlineDTO;
import com.scorpio.scbasics.bizviprecord.dto.BizVipRecordDTO;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author scorpio
 * @date 2020-10-13
 */
@Service
public class BizUserServiceImpl extends BaseServiceImpl<BizUserMapper, BizUserEntity> implements IBizUserService {

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public BizUserEntity selectById(Long id) {
        return baseDao.selectById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param entity 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<BizUserEntity> selectList(BizUserEntity entity) {
        return baseDao.list(entity);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param entity 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int save(BizUserEntity entity) {
        return baseDao.insert(entity);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param entity 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int update(BizUserEntity entity) {
        return baseDao.updateById(entity);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteByIds(Long[] ids) {
        return baseDao.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteById(Long id) {
        return baseDao.deleteById(id);
    }

    @Override
    public BizUserDTO getMyInfo(String userId,String mobile) {
        StringBuffer sql=new StringBuffer(" where 1=1 ");

        if(!StringUtils.isEmpty(userId)){
            sql.append(" u.id ="+userId);
        }else if(!StringUtils.isEmpty(mobile)){
            sql.append(" u.mobile ="+mobile);
        }else{
            return null;
        }

        return baseDao.getMyInfo(sql.toString());
    }

    @Override
    public BizUserDTO GetUser(int user_id, int to_user_id, String lat, String lng) {
        return baseDao.GetUser(user_id,to_user_id,lat,lng);
    }

    @Override
    public String GetPwdByID(int user_id) {
        return baseDao.GetPwdByID(user_id);
    }

    @Override
    public int ChangePwd(String mobile, String user_id, String newPwd) {
        StringBuffer sql=new StringBuffer(" where 1=1 ");
        if(!StringUtils.isEmpty(mobile)){
            sql.append(" and mobile="+mobile);
        }else if(!StringUtils.isEmpty(user_id)){
            sql.append(" and user_id="+user_id);
        }else{
            return 0;
        }
        return baseDao.ChangePwd(sql.toString(),newPwd);
    }

    @Override
    public int ChangeMobile(int user_id, String mobile) {
        return baseDao.ChangeMobile(user_id,mobile);
    }

    @Override
    public int ModifyIsTrue(BizUserEntity bizUserEntity) {
        return baseDao.ModifyIsTrue(bizUserEntity.getId().intValue(),bizUserEntity.getIsTrue().intValue(),bizUserEntity.getBestFrame());
    }

    @Override
    public int ModifyAuthStatus(int user_id, int auth_status, int goddess_status) {
        return baseDao.ModifyAuthStatus(user_id,auth_status,goddess_status);
    }

    @Override
    public int ModifyAuthBestFrame(int user_id, String best_frame) {
        return  baseDao.ModifyAuthBestFrame(user_id, best_frame);
    }

    @Override
    public int SetMemorandum(BizMemorandumDTO m) {
        return baseDao.SetMemorandum(m);
    }

    @Override
    public BizMemorandumDTO GetMemorandum(int user_id, int to_user_id) {
        return baseDao.GetMemorandum(user_id,to_user_id);
    }

    @Override
    public int ChangeOnLine(int user_id, int online, String last_online_time) {
        return baseDao.ChangeOnLine( user_id,  online, last_online_time);
    }

    @Override
    public BizUserDTO GetNickNameGroup(int user_id, String to_user_ids) {
        return baseDao.GetNickNameGroup(user_id, to_user_ids);
    }

    @Override
    public int ModifyLianMai(int user_id, int is_lianmai) {
        return baseDao.ModifyLianMai(user_id, is_lianmai);
    }

    @Override
    public int ModifyHide(int user_id, int is_hide) {
        return baseDao.ModifyHide(user_id, is_hide);
    }

    @Override
    public int ModifyOnline(int user_id, int is_secrecy) {
        return baseDao.ModifyOnline(user_id, is_secrecy);
    }

    @Override
    public int ModifyHideDistance(int user_id, int hide_distance) {
        return baseDao.ModifyHideDistance(user_id, hide_distance);
    }

    @Override
    public int ModifyHideWechat(int user_id, int hide_wechat) {
        return baseDao.ModifyHideWechat(user_id, hide_wechat);
    }

    @Override
    public int ExistLocation(int user_id) {
        return baseDao.ExistLocation(user_id);
    }

    @Override
    public int AddUserLocation(BizLocationDTO location) {
        return baseDao.AddUserLocation(location);
    }

    @Override
    public int ModifyUserLocation(BizLocationDTO location) {
        return baseDao.ModifyUserLocation(location);
    }

    @Override
    public int SetUserLocation(BizLocationDTO location) {
        return baseDao.SetUserLocation(location);
    }

    @Override
    public int SetGoddessAuth(BizGoddessAuthDTO ga) {
        return baseDao.SetGoddessAuth(ga);
    }

    @Override
    public BizGoddessAuthDTO GetGoddessAuth(int user_id) {
        return baseDao.GetGoddessAuth(user_id);
    }

    @Override
    public int GetUserCount(int user_id, int type) {
        return baseDao.GetUserCount(user_id, type);
    }

    @Override
    public int GetUserCount(int user_id, int to_user_id, int type) {
        return baseDao.GetUserCount(user_id, to_user_id, type);
    }

    @Override
    public int AddUserCount(int user_id, int to_user_id, int type) {
        return baseDao.AddUserCount(user_id, to_user_id, type);
    }

    @Override
    public int AddSms(String mobile, int verify_code, int type) {
        return baseDao.AddSms(mobile, verify_code, type);
    }

    @Override
    public BizSmsDTO GetSmsByMobile(String mobile, int type) {
        return baseDao.GetSmsByMobile(mobile, type);
    }

    @Override
    public BizVipRecordDTO GetVipRecord(int user_id) {
        return baseDao.GetVipRecord(user_id);
    }

    @Override
    public int RemoveVipRecord(int user_id) {
        return baseDao.RemoveVipRecord(user_id);
    }

    @Override
    public int ModifyIsVip(int user_id) {
        return baseDao.ModifyIsVip(user_id);
    }

    @Override
    public int AddUserOnlineTime(BizUserOnlineDTO uo) {
        return baseDao.AddUserOnlineTime(uo);
    }

    @Override
    public BizUserDTO GetUserDetail(int user_id) {
        return baseDao.GetUserDetail(user_id);
    }


}
